Skip to content

Prevent excessive recursions in expression parser - #468

Open
goneall wants to merge 2 commits into
masterfrom
parseoverflow
Open

goneall wants to merge 2 commits into
masterfrom
parseoverflow

Conversation

@goneall

@goneall goneall commented Nov 24, 2026

Copy link
Copy Markdown
Member

Prevents possible stack overflow with very large expressions or
expressions that have a large number of parens or pluses.

Changes the tokenizer to use streams.

Adds a cap to the number of tokens - currently, 1,000.

Prevents possible stack overflow with very large expressions or
expressions that have a large number of parens or pluses.

Changes the tokenizer to use streams.

Adds a cap to the number of tokens - currently, 1,000.

Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
Signed-off-by: Gary O'Neall <gary@sourceauditor.com>

@pmonks pmonks left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Just out of interest, what's the largest / most complex SPDX expression you've encountered? Just curious what precipitated this as much as anything.

@goneall

goneall commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Just out of interest, what's the largest / most complex SPDX expression you've encountered? Just curious what precipitated this as much as anything.

I've run into some really large generated expressions where the tool rolls up all discovered licenses for a package as "AND's", pretty comfortably less than the 1,000 tokens, however.

The issue was submitted from based on a security review of the code.

@pmonks

pmonks commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

A situation where expression canonicalisation might help!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants